package com.ohc.leetcode.数组.repect;

import java.util.Arrays;

/**
 * 2022年5月3日23:08:14
 */
public class 移除元素01 {

    public static int removeElement(int[] nums, int val) {
        int temp = 0;
        int size = nums.length;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == val) {
//                for (int j = i; j < nums.length - 1; j++) {
//                    nums[j] = nums[j + 1];
//                }
//                i--;
                size--;
            }
        }

        System.out.println("size = " + size);
        for (int i = 0; i < size; i++) {
            System.out.println("nums[i] = " + nums[i]);
        }
        System.out.println("nums = " + nums);
        return 0;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{3, 2, 2, 3};
        int i = removeElement(arr, 3);
        System.out.println("i = " + i);
    }
}
